package com.usian.common.exception;

import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;


/**
 * ClassName: ExceptionCache
 * Author:   WGG
 * Date:    2022-11-2022/11/10-16:15
 * Version: 1.0
 * Description:
 */
@RestControllerAdvice
@Log4j2
public class ExceptionCatch {

    @ExceptionHandler
    public ResponseResult exception(Exception e){
        e.printStackTrace();
        //记录日志
        log.error("catch exception {}",e.getMessage());
        //返回通用异常类
        return ResponseResult.errorResult(503,"要想马儿跑，得给马儿吃嫩草。。。");
    }

}
